package org.geek4j.controller;

import java.util.Random;

import org.geek4j.domain.Person;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Geek4J
 * @description PersonController
 */
@Controller
@RequestMapping("Person")
public class PersonController {

	/**
	 * @author Geek4J
	 * @description sayHello to somebody
	 */
	@RequestMapping("sayHello")
	public ResponseEntity<String> sayHello(String name) {
		return ResponseEntity.ok("Hi, {}!".replace("{}", name));
	}

	/**
	 * @author Geek4J
	 * @description retrievePerson
	 */
	@RequestMapping("retrievePerson")
	public ResponseEntity<Person> retrievePerson() {
		Person person = new Person();
		person.setAge(new Random().nextInt(10) + 7);
		person.setName("Geek4J");
		return ResponseEntity.ok(person);
	}
}
